#include "ManageAPI.h"
#include "Utils.h"
#include "errlog.h"
//#include <unistd.h>

int main (int argc, char* argv[])
{
  double t;
  cast_set_err_level(-1);
  CAST::Utils global_utils; //instanciate static memeber properties
  CAST::Manager_API ast_manager;
  ast_manager.open("192.168.1.20:5038");
  ast_manager.login("dudu", "mysecret");
  CAST::Response x;
  
  fflush(NULL);
  x=ast_manager.absoluteTimeout("Zap/1-1",20);
  x.dump();
  x=ast_manager.changeMonitor("Zap/1-1","/tmp/testMonitor");
  x.dump();
  x=ast_manager.command("zap show status");
  x.dump();
  x=ast_manager.extensionState("1236", "home");
  x.dump();
  x=ast_manager.getVar("Zap/1-1", "CALLID");
  x.dump();
  x=ast_manager.hangUp("Zap/1-1");
  x.dump();
  x=ast_manager.iaxPeers();
  x.dump();
  x=ast_manager.listCommands();
  x.dump();
  x=ast_manager.mailboxCount("1234");
  x.dump();
  x=ast_manager.mailboxStatus("1235");
  x.dump();
  x=ast_manager.monitor("Zap/1-1", "/tmp/monitorzap1");
  x.dump();
  x=ast_manager.originate("Zap/1-1");
  x.dump();
  x=ast_manager.parkedCalls();
  x.dump();  
  x=ast_manager.ping();
  x.dump();
  //  x=ast_manager.queueAdd(const char* queue, const char* interfaceId,
  //	     unsigned int penalty=0, bool isPaused=false, const char* actionId=NULL, char* msg=NULL);
  //x.dump();
  //x=ast_manager.queueRemove(const char* queue, const char* interfaceId, const char* actionId=NULL, char* msg=NULL);
  //x.dump();
  x=ast_manager.queues();
  x.dump();
  x=ast_manager.queueStatus();
  x.dump();
  x=ast_manager.redirect("Zap/1-1", NULL,"1236", "default",1);
  x.dump();
  
  //x=ast_manager.setCDRUserField(const char* userField, const char* channel, const char* append,
  //		    const char* actionId=NULL, char* msg=NULL);
  //x.dump();
  x=ast_manager.setVar("Zap/1-1", "CALLID", "8888"); 
  x.dump();
  x=ast_manager.status("Zap/1-1");
  x.dump();
  x=ast_manager.stopMonitor("Zap/1-1");
  x.dump();
  x=ast_manager.zapDialOffHook("Zap/1-1", "1234");
  x.dump();
  x=ast_manager.zapDNDOff("Zap/1-1");
  x.dump();
  x=ast_manager.zapDNDOn("Zap/1-1");
  x.dump();
  x=ast_manager.zapHangUp("Zap/1-1");
  x.dump();
  x=ast_manager.zapShowChannels();
  x.dump();
  x=ast_manager.zapTransfer("Zap/1-1");
  x.dump();
  x=ast_manager.logOff();
  x.dump();
  return 0;
}
